home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 25
/
Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso
/
Aminet
/
util
/
pack
/
xpk_Source.lha
/
xpk_Source
/
Oberon
/
examples
/
xsum.mod
< prev
next >
Wrap
Text File
|
1998-02-08
|
2KB
|
69 lines
(*************************************************************************
:Program. XSum.mod
:Contents. sums up all bytes in a compressed or uncompressed file
:Author. Hartmut Goebel [hG]
:Language. Oberon
:Translator. Amiga Oberon V2.25
:History. V0.9, 09 Jan 1992 Hartmut Goebel [hG]
:History. V1.0, 11 Jul 1992 [hG] ·now more Oberon-like :-)
:Date. 11 Jul 1992 15:12:20
*************************************************************************)
MODULE XSum;
IMPORT
io,
arg:= Arguments,
e := Exec,
s := SYSTEM,
u := Utility,
xpk:= XpkMaster;
(* This is a typical read-and-process xpk application. Try it out... XSum a
* file, then compress it and XSum it again. The result should be the same.
*)
VAR
OutBuf: POINTER TO ARRAY MAX(LONGINT)-1 OF CHAR;
OutLen, OutBufLen, i: LONGINT;
Sum: LONGINT;
Arg: e.STRING;
ErrBuf: ARRAY xpk.errMsgSize+1 OF CHAR;
PROCEDURE End(text: ARRAY OF CHAR);
BEGIN
io.WriteString(text); io.WriteLn;
HALT(10);
END End;
BEGIN
Sum := 0; i := 0;
IF arg.NumArgs() # 1 THEN End("Usage: XSum <filename>"); END;
arg.GetArg(1,Arg);
IF 0 # xpk.UnpackTags(
xpk.inName, s.ADR(Arg), (* The file name to be read *)
xpk.getError, s.ADR(ErrBuf), (* A pointer to the error message buffer *)
xpk.getOutBuf, s.ADR(OutBuf), (* Sets a pointer to the output buffer *)
xpk.getOutLen, s.ADR(OutLen), (* Sets the number of bytes written *)
xpk.getOutBufLen,s.ADR(OutBufLen),(* Sets the length of the output buffer *)
xpk.passThru, e.true, (* Will pass through uncompressed data *)
u.done)
THEN End(ErrBuf); END;
REPEAT
INC(Sum,ORD(OutBuf[i]));
INC(i);
UNTIL i = OutLen;
io.WriteInt(Sum,0); io.WriteLn;
CLOSE
IF OutBuf # NIL THEN e.FreeMem(OutBuf,OutBufLen); END;
END XSum.